package com.yingsheng.bi.hks.template.processor;

import com.yingsheng.bi.hks.template.events.AdviceEvent;
import com.yingsheng.bi.hks.template.events.Event;

public abstract class AroundProcessor extends InnerProcessor {

    @Override
    public void exec(Event event) {
        if (event instanceof AdviceEvent) {
            AdviceEvent adviceEvent = (AdviceEvent) event;
            Object input = adviceEvent.getInput();
            execInner(event);
            adviceEvent.setInput(input);
        } else {
            execInner(event);
        }
    }

    protected void execInner(Event event) {
        execBefore(event);
        super.execInner(event);
        execAfter(event);
    }

    public abstract void execBefore(Event event);

    public abstract void execAfter(Event event);

}
